/*
 * @lc app=leetcode.cn id=53 lang=cpp
 *
 * [53] 最大子序和
 */

// @lc code=start
class Solution {
public:
    int maxSubArray(vector<int>& nums) {
        int wzz = nums[0];
        int res = wzz;

        for(int i = 1 ; i < nums.size();i++)
        {
            wzz = max(wzz + nums[i],nums[i]);
            res = max(wzz,res);
        }
        return res;
    }
};
// @lc code=end

